In [9]:
dragon 0 = mempty
In [ ]:
-- a -> aRbFR
-- b -> LFaLb
-- d0 = "Fa"
In [ ]:
In [6]:
import IHaskell.Display
data Answer = Answer
-- Make it "displayable"
instance IHaskellDisplay Answer where
-- List of two kinds of Display: html and plain text
display value = return $ Display [htmlDisplay, txtDisplay]
where
-- HTML Display
-- htmlDisplay = html "<div style=\"color: red\">The answer is 42!</div>"
htmlDisplay = html "<svg width=\"100\" height=\"100\"> \n\
\ <circle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"green\" stroke-width=\"4\" fill=\"yellow\" /> \n\
\ </svg>"
-- Plain Text Display
txtDisplay = plain "42"
-- Display an instance of our type
Answer
In [8]:
hilbert 0 = mempty
hilbert n = hilbert' (n-1) # reflectY <> vrule 1
<> hilbert (n-1) <> hrule 1
<> hilbert (n-1) <> vrule (-1)
<> hilbert' (n-1) # reflectX
where
hilbert' m = hilbert m # rotateBy (1/4)
diagram :: Diagram B
diagram = strokeT (hilbert 6) # lc silver
# opacity 0.3
In [ ]:
> import Diagrams.Backend.SVG.CmdLine
> {-# LANGUAGE NoMonomorphismRestriction #-}
>
> import Diagrams.Prelude
>
> hilbert 0 = mempty
> hilbert n = hilbert' (n-1) # reflectY <> vrule 1
> <> hilbert (n-1) <> hrule 1
> <> hilbert (n-1) <> vrule (-1)
> <> hilbert' (n-1) # reflectX
> where
> hilbert' m = hilbert m # rotateBy (1/4)
>
> example = frame 1 . lw medium . lc darkred
> . strokeT $ hilbert 5
> main = mainWith (example :: Diagram B)
In [ ]:
-- TODO
-- https://github.com/timbod7/haskell-chart/wiki
-- http://nbviewer.jupyter.org/github/gibiansky/IHaskell/blob/master/notebooks/IHaskell.ipynb
In [ ]:
-- try to present with https://github.com/damianavila/RISE